Repository navigation
fix: use the first column as the default LabelValueTable label - #152
Merged
Merged
Conversation
LabelValueTable() is documented to use the first column as the label when label_list is None, but the default was the first column name itself, a string. The validation loop then iterated over its characters, so any table whose first column name is longer than one character raised "TableError: Invalid label prefix: <first letter>.". CliTable.LabelValueTable() falls back to the same default when the template has no Key values. Wrap the default in a list and add a test with multi-character column names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TextTable.LabelValueTable()says it uses the first column as the label whenlabel_listis None. The default was set toself._Header()[0], which is the column name itself, a string. The validation loop and theheader in label_listcheck then work on single characters. Any table whose first column name is longer than one character raisesTableError: Invalid label prefix: <first letter>.:CliTable.LabelValueTable()falls back to this default when the template has noKeyvalues, so it fails the same way.This change wraps the default in a list, so
LabelValueTable()gives the same output asLabelValueTable([<first column>]). Explicitlabel_listarguments behave as before.The existing
testTableWithLabelsuses a first column nameda, which hides the problem. The new test uses multi-character column names. It checks the expected output and that the default matches the explicit first-column call.Testing:
TableError: Invalid label prefix: I.) and passes after it.pytest tests: 109 passed, 28 subtests passed. The two existing FutureWarnings fromclitable.pyare unchanged.git diff --checkis clean.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.